<?php
/*
 * Sips Payment Plugin Class
 */
class RM_Plugin_Sips extends RM_Payments_Plugin
{    

    /**
     * Public constructor
     */
    public function  __construct() {
        $this->name = 'Sips';
        $this->_ipnLogFile = RM_Environment::getConnector()->getCorePath().DIRECTORY_SEPARATOR.'userdata'.DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR.'sips_log.txt';

        
    }

    /**
     * collects the payment data and sends to the Sips Payment Provider
     */
    public function Process($bookingRef, $ccArray, $userData){

       
    }

    /**
     * We don't need to present this plugins under admin tree menu 'Plugins', only on Config leaf
     * 
     * @return null
     */
    public function getNode(){
        return null;
    }


    /**
     * get the authorize.net config
     *
     * @return   array
     */
    private function _getConfig() {
        $authorizenetObj = new RM_SipsConfig;
        $value = $authorizenetObj->getSettings()->current()->toArray();
        return $value;
    }

    /**
     * used to log results to the ipn log file so we can see whats happening
     *
     * @param boolean $success if this is a successful or fail log
     */
    private function _logResults($msg)
    {
        if (!$this->_ipnLog) return;  // is logging turned off?

        // Timestamp
        $text = '['.date('m/d/Y g:i A').'] - ';
        $text .= $msg;

        // Write to log
        $fp = fopen($this->_ipnLogFile, 'a');
        fwrite($fp, $text . "\n\n");
        fclose($fp);  // close file
    }
}